#ifndef BALL_H
#define BALL_H

#include <QObject>
#include <QRect>
#include <QVariantAnimation>

class Vector2DAnima : public QVariantAnimation
{
    Q_OBJECT
public:
    Vector2DAnima(QVector2D *v2d, QObject *parent = nullptr);
    virtual ~Vector2DAnima();

    QVector2D keyValueAt(qreal step) const;


protected:
    QVector2D *m_v2d;
    void updateCurrentValue(const QVariant &value) override;
    // QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const override;

signals:
    void deleted();

};

class Ball : public QObject
{
    Q_OBJECT
public:
    double velocity;
    double resistAcc;
    double offsetSum;
    int radius;
    QRect frame;
    Ball(QObject *parent = nullptr);
    virtual ~Ball();
    void pushLeft();
    void pushRight();
    Vector2DAnima *createNewAccAnima();
    QVector2D *addNewAcc(const QVector2D &v2d);
    bool removeAcc(QVector2D *v2d);
    bool removeAccAnima(Vector2DAnima *anima);
    QVector2D sumOfComponentsAcc();

private:
    Vector2DAnima *pushBallAnima;
    QVector<QVector2D*> *componentsAccList;
    QVector<Vector2DAnima*> *accAnimasList;
};

#endif // BALL_H
